import { Controller, Get, Inject, Logger, LoggerService } from '@nestjs/common';
import { AppService } from './app.service';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';

@Controller()
export class AppController {
  private readonly logger = new Logger(AppController.name); // ConsoleLogger nest 内置的日志记录器
  constructor(private readonly appService: AppService) {}

  @Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly winstonlogger: LoggerService
  @Get('hello')
  getHello(): string {
    this.logger.error('这是Nest内置的日志记录器');
    this.logger.warn('这是Nest内置的日志记录器');
    this.logger.log('这是Nest内置的日志记录器');
    this.winstonlogger.error('自定义错误日志记录', 'stack', AppService.name);
    this.winstonlogger.warn('自定义警告日志记录', AppService.name);
    this.winstonlogger.log('自定义日志记录', AppService.name);

    return this.appService.getHello();
  }
}
